<?php
namespace app\admin\model;

use think\Model;

class ShippingTemplate extends Model
{
    protected $name = 'shipping_template';
    
    // 关联运费规则
    public function rules()
    {
        return $this->hasMany('ShippingRule', 'template_id');
    }
    
    // 获取计费方式文本
    public function getTypeTextAttr($value, $data)
    {
        $types = [1 => '按件数', 2 => '按重量', 3 => '按体积'];
        return $types[$data['type']] ?? '';
    }
}